<?php
namespace app\api\controller;

use app\api\utils\Utils;
use think\process\exception\Timeout;
use Symfony\Component\Finder\Comparator\DateComparator;

class Home
{
    public function index ()
    {
        $swagger = \Swagger\scan(__DIR__);
        return $this->response($swagger, 'json', 200);
    }

    public function notifies()
    {
        $data = [
            '第一条通知：111',
            '第二条通知：222',
            '第三条通知：333',
        ];
        return api_response(['get', 'post'], [], $data);
    }

    public function banners()
    {
        $domain = config('queue.domain');
        $data = [
            ['imgPath' => $domain . '/static/img/2.png', 'link' => ''],
            ['imgPath' => $domain . '/static/img/1.png', 'link' => ''],
            ['imgPath' => $domain . '/static/img/3.png', 'link' => ''],
        ];
        return api_response(['get', 'post'], [], $data);
    }

    public function sightLists()
    {
        $domain = config('queue.domain');
        $field = ['token', 'limit', 'offset'];
        $data = [
            ['businessCode' => 'B01', 'munitId' => 'S1', 'imgPath' => $domain . '/static/img/1.png', 'munitName' => '景区名称一'],
            ['businessCode' => 'B02', 'munitId' => 'S2', 'imgPath' => $domain . '/static/img/2.png', 'munitName' => '景区名称二'],
            ['businessCode' => 'B03', 'munitId' => 'S3', 'imgPath' => $domain . '/static/img/3.png', 'munitName' => '景区名称三'],
        ];
        return api_response(['post', 'get'], [], $data, ['total'=>3]);
    }

    /** 热门推荐 */
    public function hots()
    {
        $data = [
            ['productCode' => 'c1', 'productName' => '门票一', 'sellPrice' => "230.00", 'imgPath' => ''],
            ['productCode' => 'c2', 'productName' => '门票二', 'sellPrice' => "120.00", 'imgPath' => ''],
            ['productCode' => 'c3', 'productName' => '门票三', 'sellPrice' => "113.00", 'imgPath' => ''],
            ['productCode' => 'c4', 'productName' => '门票四', 'sellPrice' => "190.00", 'imgPath' => ''],
        ];
        return api_response(['get', 'post'], [], $data);
    }

    //
    public function ticketLists()
    {
        $field = ['token', 'limit', 'offset'];

        $data = [
            ['productCode' => 'c1', 'imgPath' => '', 'productName' => '门票一', 'stars' => 3.5, 'productDec' => '我是描述', 'sellPrice' => 110, 'munitName' => '景点名', 'munitLong' => '12312312.23', 'munitLat' => '1231223.322'],
            ['productCode' => 'c2', 'imgPath' => '', 'productName' => '门票二', 'stars' => 4, 'productDec' => '我也是描述', 'sellPrice' => 130, 'munitName' => '景点名', 'munitLong' => '12312312.23', 'munitLat' => '1231223.322'],
        ];
        return api_response(['post', 'get'], [], $data, ['total'=>2]);
    }

    //搜索
    public function search()
    {
        $field = ['token', 'limit', 'offset', 'keywords'];
        $data = [
            ['businessCode' => 'c1', 'imgPath' => '', 'stars' => 3.5, 'munitDesc' => '我是描述', 'showPrice' => '110.00', 'munitName' => '景点名', 'munitLong' => '12312312.23', 'munitLat' => '1231223.322'],
            ['businessCode' => 'c2', 'imgPath' => '', 'stars' => 4, 'munitDesc' => '我也是描述', 'showPrice' => '130.00', 'munitName' => '景点名', 'munitLong' => '12312312.23', 'munitLat' => '1231223.322'],
        ];
        return api_response(['get', 'post'], [], $data, ['total'=>2]);
    }

    /** 
     * @SWG\Info(title="景区详情", version="0.1")
     * @SWG\Post(
     *     path="/api/sightDetail",
     *     summary="景区详情",
     *     tags={"API"},
     *     description="获取景区详情",
     *     operationId="getSightDetail",
     *     produces={"application/json"},
     *     @SWG\Parameter(
     *         name="token",
     *         in="formData",
     *         description="令牌",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description=""
     *     )
     * 
     * )
     * @return [type] [description]
     */
    public function sightDetail()
    {
        $data = [
            'businessCode'       => '212031',
            'imgPath'            => '',
            'munitName'          => '云南大理XXXXXXX景区',
            'munitDesc'          => '景点介绍',
            'stars'              => '4.8',
            'commentNum'         => '2896',
            'munitAddress'        => '云南省XXXXXX101号',
            'ticketTime'         => '2017071813',
            'grade'              => 1,
            'openTime'           => '夏季7:00-19:00 冬季7:30-18:30',
            'mapX'               => '30.654453',
            'mapY'               => '104.072113',
            'prompt'             => '1.门票仅在购买后当天有效，出园再入院，需再次购票
                                2.景区门票包含：景区大门票（其他项目需自费）
                                3.为保证取票、入园顺利......',
            //预订须知
            'bookingInformation' => '需提前1天预定，有效期5天，每人限购10张',
        ];
        return Utils::validateRequestMethod(['get', 'post'])
            ->validateParams(true, [])
            ->response($data);
    }

    //景区商品信息列表查询
    public function sightProductList()
    {
        $field = ['token', 'businessCode', 'limit', 'offset'];
        $data = [
            [
                'productName' => '崇圣寺三塔门门票',
                'onSellCode'  => '213425',
                'sellPrice'   => '300.00元',
                'showPrice'   => '200.00元',
            ],
            [
                'productName' => '崇圣寺三塔门门票',
                'onSellCode'  => '213425',
                'sellPrice'   => '300.00元',
                'showPrice'   => '200.00元',
            ],
        ];
        return Utils::validateRequestMethod(['get', 'post'])
            ->validateParams(true, [])
            ->response($data, ['total'=>2]);
    }

    //景区商品详情
    public function sightProductDetail()
    {
        $data = [
            'onSellCode' => '213425',
            'productName' => '崇圣寺三塔门门票',
            'sellPrice'  => '300.00元',
            'showPrice'  => '200.00元',
            'useTips' => '2017年XX日前使用',
            'limitNum' => 10,
            'limitDayNum' => 2,
            'returnRule' => '因本站所售各类票品具有有效时间及有限数量的特殊性质，在售出后将影响二次销售，因此本站所售各类票品（包括并不限于演出门票、体育赛事门票、景点参观门票、电影票以及各类电子票等）如非活动变更、活动取消、票品错误的原因外，不提供退换票品服务。如因活动变更、活动取消、票品错误的原因发生退换货，产生的退换货配送运费由非常票务承担，用户发出快递后可联系非常票务客服人员，非常票务向用户返还实际发生的配送运费，非上述原因产生退换货的配送运费由用户承担。已付款订单因发生退换货需全额或差额向用户退款时，非常票务网站将于收到用户退回商品之日起7日内为用户办理退回订单相应款项操作。'
        ];

        return Utils::validateRequestMethod(['get', 'post'])
            ->validateParams(true, [])
            ->response($data);
    }

}
